package judlawei.gui;

import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.AbstractButton;
import javax.swing.AbstractListModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.LayoutStyle;

import judlaw.model.bean.docjud.DocumentoJuridico;

import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;

public class EditorAtributos extends JPanel{
    
    private JFrame ajusteAtributo;
    private JButton ajustar;
    private JButton atualizar;
    private JButton cancelar;
    private JScrollPane visualizadorAtributos;
    private JList selecionadorAtributos;
    private DocumentoJuridico doc;
    
    
    public EditorAtributos(){
        
        initComponents();       
        construirLayout();
        inicializarListeners();
    }
    
    private void initComponents(){
        ajustar = new JButton();
        atualizar = new JButton();
        cancelar = new JButton();
        visualizadorAtributos = new JScrollPane();
        selecionadorAtributos = new SelecionadorAtributos();
        doc = new DocumentoJuridico();
        
        ajustar.setText("Ajustar");
        atualizar.setText("Atualizar");
        cancelar.setText("Cancelar");
        
        
    }

    public void addDocumento(DocumentoJuridico d){
        this.doc = d;
    }
    
    
    
    
    
    
    
    
    private void construirLayout(){
        GroupLayout editorAtributosLayout = new GroupLayout(this);
        this.setLayout(editorAtributosLayout);
        editorAtributosLayout.setHorizontalGroup(
            editorAtributosLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(GroupLayout.Alignment.TRAILING, editorAtributosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(visualizadorAtributos, GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(editorAtributosLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                    .addComponent(ajustar, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(atualizar, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cancelar, GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE))
                .addContainerGap())
        );
        editorAtributosLayout.setVerticalGroup(
            editorAtributosLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(editorAtributosLayout.createSequentialGroup()
                .addGroup(editorAtributosLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(editorAtributosLayout.createSequentialGroup()
                        .addComponent(ajustar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(atualizar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancelar))
                    .addComponent(visualizadorAtributos, GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE))
                .addContainerGap())
        );
    }
   
    private void inicializarListeners(){
        
        ajustar.addMouseListener(new MouseAdapter() {
            
            public void mouseClicked(MouseEvent e) {
                if(ajusteAtributo == null)
                    ajusteAtributo = new AjusteAtributo();
                ajusteAtributo.setVisible(true);
            }
            
        });
        
    }
    
}
